//
//  SetUpController.m
//  Youhuiju
//
//  Created by liuovyue on 16/8/10.
//  Copyright © 2016年 yutenys. All rights reserved.
//

#import "SetUpController.h"
#import "CellSetUp.h"
#import "DataController.h"
#import "ReceiveController.h"
#import "SecurityCenterViewController.h"
#import "AboutAppViewControllerr.h"
#import <SDWebImage/SDImageCache.h>
#import "SetupCach.h"
#define filePathNew [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject]

@interface SetUpController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong)UITableView *tableView;
@property (nonatomic, strong)NSArray *arr;

@property (nonatomic, strong)UIButton *buttonOut;
@property (nonatomic, strong)UIView *viewBar;
@property (nonatomic, strong)UILabel *labelTitle;

@property (nonatomic, strong)UIImageView *imageViewBar;

@property (nonatomic, strong)UIButton *buttonReturn;
@property (nonatomic, strong)UIButton *buttonFunction;
@property (nonatomic, strong)UIView *viewFunction;
@property (nonatomic, strong)UIButton *buttonRemove;

@property (nonatomic, copy)NSString *trackViewUrl;
@property (nonatomic, strong)UIView *viewVersion;
@property (nonatomic, strong)UIView *viewCache;
@property (nonatomic, strong)UIButton *buttonCache;

@end

@implementation SetUpController




- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Do any additional setup after loading the view.
    self.arr = @[@"个人资料",@"收货地址",@"安全中心",@"检查更新",@"清除缓存",@"关于APP"];
    self.view.backgroundColor = [UIColor whiteColor];
    [self createNavigationBar];
    [self createTableView];
    [self createButton];
    
    self.tabBarController.tabBar.hidden = YES;
}

- (void)createNavigationBar{
    
    self.viewBar = [[UIView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 64)];
    self.viewBar.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.viewBar];

    
    
    self.labelTitle = [[UILabel alloc]init];
    self.labelTitle.text = @"设置";
    self.labelTitle.textAlignment = NSTextAlignmentCenter;
    
    
    self.labelTitle.font = [UIFont systemFontOfSize:18*FitW];
    [self.viewBar addSubview:self.labelTitle];
    
    [_labelTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        
        //make.top.equalTo(self.viewBar.mas_top);
        make.left.equalTo(self.viewBar.mas_left).offset(100*FitW);
        make.right.equalTo(self.viewBar.mas_right).offset(-100*FitW);
        make.bottom.equalTo(self.viewBar.mas_bottom).offset(-14*FitH);
        
        
        
    }];
//返回按钮
    self.buttonReturn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.buttonReturn setImage:[UIImage imageNamed:@"zfanhuijian"] forState:UIControlStateNormal];
    [self.buttonReturn addTarget:self action:@selector(tuihuiAcion:) forControlEvents:UIControlEventTouchUpInside];
    [self.viewBar addSubview:self.buttonReturn];
    
    [_buttonReturn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.viewBar.mas_left).offset(17*FitW);
        make.width.mas_equalTo(22*FitW);
        make.height.mas_equalTo(22*FitH);
        make.bottom.equalTo(self.viewBar.mas_bottom).offset(-13*FitH);
        
        
        
    }];
    
//功能按钮
    self.buttonFunction = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.buttonFunction setImage:[UIImage imageNamed:@"function"] forState:UIControlStateNormal];
    [self.buttonFunction addTarget:self action:@selector(functionAcion:) forControlEvents:UIControlEventTouchUpInside];
    [self.viewBar addSubview:self.buttonFunction];
    
    [_buttonFunction mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.equalTo(self.viewBar.mas_right).offset(-17*FitW);
        make.width.mas_equalTo(22*FitW);
        make.height.mas_equalTo(22*FitH);
        make.bottom.equalTo(self.viewBar.mas_bottom).offset(-13*FitH);
        
        
        
    }];
    
    
}

#pragma mark - 退回按钮点击功能
- (void)tuihuiAcion:(UIButton *)button {
    
    [self.navigationController popViewControllerAnimated:YES];
    self.tabBarController.tabBar.hidden = NO;
    
    
    
}
#pragma mark - 功能按钮
- (void)functionAcion:(UIButton *)button {
    
    self.buttonRemove = [UIButton buttonWithType:UIButtonTypeSystem];
    
    [self.buttonRemove addTarget:self action:@selector(removeAcion:) forControlEvents:UIControlEventTouchUpInside];
    self.buttonRemove.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
    [self.view addSubview:self.buttonRemove];
    self.viewFunction = [[UIView alloc]init];
    self.viewFunction.backgroundColor = [UIColor whiteColor];
    [self.viewFunction.layer setMasksToBounds:YES];
    [self.viewFunction.layer setBorderWidth:1.0];
    self.viewFunction.layer.borderColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:1.0].CGColor;
    
    [self.buttonRemove addSubview:self.viewFunction];
    [self.viewFunction mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view.mas_top).offset(15*FitH);
        make.right.equalTo(self.view.mas_right).offset(-20*FitW);
        make.height.mas_equalTo(90*FitH);
        make.width.mas_equalTo(110*FitW);
    }];
    UIButton *buttonNews = [UIButton buttonWithType:UIButtonTypeSystem];
    [buttonNews setTitle:@"    消息" forState: UIControlStateNormal];
    buttonNews.titleLabel.font = [UIFont systemFontOfSize:18*FitW];
    buttonNews.tintColor = [UIColor blackColor];
    [buttonNews addTarget:self action:@selector(newsAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.viewFunction addSubview:buttonNews];
    [buttonNews setImage:[UIImage imageNamed:@"zxiaoxi"] forState:UIControlStateNormal];
    [buttonNews mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.viewFunction.mas_top);
        make.right.equalTo(self.viewFunction.mas_right);
        make.left.equalTo(self.viewFunction.mas_left);
        make.height.mas_equalTo(45*FitH);
    }];
    UIButton *buttonFirst = [UIButton buttonWithType:UIButtonTypeSystem];
    [buttonFirst setTitle:@"    首页" forState: UIControlStateNormal];
    buttonFirst.titleLabel.font = [UIFont systemFontOfSize:18*FitW];
    buttonFirst.tintColor = [UIColor blackColor];
    [buttonFirst addTarget:self action:@selector(fitstAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.viewFunction addSubview:buttonFirst];
    [buttonFirst setImage:[UIImage imageNamed:@"shouye"] forState:UIControlStateNormal];
    [buttonFirst mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.viewFunction.mas_top).offset(45*FitH);
        make.right.equalTo(self.viewFunction.mas_right);
        make.left.equalTo(self.viewFunction.mas_left);
        make.height.mas_equalTo(45*FitH);
    }];
    
    
    
}
//点击去除功能栏
- (void)removeAcion:(UIButton *)button {
    [self.viewFunction removeFromSuperview];
    [self.buttonRemove removeFromSuperview];
}
- (void)newsAction:(UIButton *)button{
    NSLog(@"消息");
    [self.viewFunction removeFromSuperview];
}
- (void)fitstAction:(UIButton *)button{
    NSLog(@"首页");
    self.tabBarController.selectedViewController = [self.tabBarController.viewControllers objectAtIndex:0];
    [self.viewFunction removeFromSuperview];
    self.tabBarController.tabBar.hidden = NO;
}

- (void)createTableView {
    
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 270*FitH) style:UITableViewStylePlain];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:_tableView];
    [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.viewBar.mas_bottom);
        make.left.equalTo(self.view.mas_left);
        make.right.equalTo(self.view.mas_right);
        make.height.mas_equalTo(270*FitH);
        
        
        
    }];
    _tableView.scrollEnabled = NO;
    [_tableView registerNib:[UINib nibWithNibName:@"CellSetUp" bundle:nil] forCellReuseIdentifier:@"CellSetUp"];
    
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.arr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    CellSetUp *cell = [tableView dequeueReusableCellWithIdentifier:@"CellSetUp"];
    cell.labelTitle.text = [self.arr objectAtIndex:indexPath.row];
    
    // NSString *path  =     [SetupCach getCacheSizeWithFilePath:filePathNew];
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 45*FitH;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    switch (indexPath.row) {
        case 0:{
            DataController *datac = [[DataController alloc]init];
            [self.navigationController pushViewController:datac animated:YES];
        }
            break;
        case 1:{
            ReceiveController *receive = [[ReceiveController alloc]init];
            [self.navigationController pushViewController:receive animated:YES];
        }
            break;
            case 2:
        {
            SecurityCenterViewController *security = [[SecurityCenterViewController alloc]init];
            
            [self.navigationController pushViewController:security animated:YES];
            
            
            
        }
            break;
            case 3:
           
        {
            
            
            self.viewVersion = [[UIView alloc]init];
            self.viewVersion.backgroundColor = [UIColor colorWithRed:0.7556 green:0.7556 blue:0.7556 alpha:0.714897629310345];
            [self.view addSubview:self.viewVersion];
            [self.viewVersion mas_makeConstraints:^(MASConstraintMaker *make) {
                
                make.top.equalTo(self.view.mas_top);
                make.bottom.equalTo(self.view.mas_bottom);
                make.right.equalTo(self.view.mas_right);
                make.left.equalTo(self.view.mas_left);
            }];
            
            UIButton *buttonRemove = [UIButton buttonWithType:UIButtonTypeCustom];
            [self.viewVersion addSubview:buttonRemove];
            [buttonRemove mas_makeConstraints:^(MASConstraintMaker *make) {
               
                make.top.equalTo(self.view.mas_top);
                make.bottom.equalTo(self.view.mas_bottom);
                make.right.equalTo(self.view.mas_right);
                make.left.equalTo(self.view.mas_left);
 
                
                
                
                
            }];
            [buttonRemove addTarget:self action:@selector(removeeAction:) forControlEvents:UIControlEventTouchUpInside];
            
            
            
            
            UIView *viewNewVersion = [[UIView alloc]init];
            viewNewVersion.backgroundColor = [UIColor whiteColor];
            [self.viewVersion addSubview:viewNewVersion];
            [viewNewVersion.layer setCornerRadius:6.0];
            [viewNewVersion mas_makeConstraints:^(MASConstraintMaker *make) {
                
                make.top.equalTo(self.view.mas_top).offset(250*FitH);
                make.bottom.equalTo(self.view.mas_bottom).offset(-275*FitH);
                make.right.equalTo(self.view.mas_right).offset(-60*FitW);
                make.left.equalTo(self.view.mas_left).offset(60*FitW);
            }];
            
            
            UILabel *labelVersion = [[UILabel alloc]init];
            labelVersion.font = [UIFont systemFontOfSize:20*FitW];
            [viewNewVersion addSubview:labelVersion];
            labelVersion.text = @"当前版本1.0";
            labelVersion.textAlignment = NSTextAlignmentCenter;
            [labelVersion mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(viewNewVersion.mas_top).offset(60*FitH);
                make.left.equalTo(viewNewVersion.mas_left);
                make.right.equalTo(viewNewVersion.mas_right);
            }];
            
            
            
//            NSError *error;
//            //kAPP_URL : http://itunes.apple.com/lookup?id=
//            //kAppId : 在iTunes connect上申请的APP ID
//            NSString *kAPP_URL = @"http://itunes.apple.com/lookup?id=";
//            NSString *kAppID = @"";
//            NSString *urlStr = [NSString stringWithFormat:@"%@%@", kAPP_URL, kAppID];
//            NSURL *url = [NSURL URLWithString:urlStr];
//            NSURLRequest *request = [NSURLRequest requestWithURL:url];
//            NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
//            
//            NSDictionary *appInfoDict = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&error];
//            
//            if (error) {
//                NSLog(@"%@", error.description);
//                return;
//            }
//            
//            NSArray *resultArray = [appInfoDict objectForKey:@"results"];
//            
//            if (![resultArray count]) {
//                NSLog(@"error : resultArray == nil");
//                return;
//            }
//            
//            NSDictionary *infoDict = [resultArray objectAtIndex:0];
//            //获取服务器上应用的最新版本号
//            CGFloat updateVersion = [infoDict[@"version"] doubleValue];
//            NSString *trackName = infoDict[@"trackName"];
//            
//            _trackViewUrl = infoDict[@"trackViewUrl"];
//            
//            //获取当前设备中应用的版本号
//            NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
//            CGFloat currentVersion = [[infoDic objectForKey:@"CFBundleVersion"] doubleValue];
//            
//            //判断两个版本是否相同
//            if (currentVersion < updateVersion) {
//                NSString *titleStr = [NSString stringWithFormat:@"检查更新：%@", trackName];
//                NSString *messageStr = [NSString stringWithFormat:@"发现新版本（%f）,是否更新", updateVersion];
//                
//                UIAlertController *alertcontroller = [UIAlertController alertControllerWithTitle:titleStr message:messageStr preferredStyle:UIAlertControllerStyleAlert];
//                UIAlertAction *action = [UIAlertAction actionWithTitle:@"取消" style: UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
//                    
//                    NSLog(@"取消");
//                }];
//                UIAlertAction *actionSure = [UIAlertAction actionWithTitle:@"确定" style: UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//                    NSLog(@"确定");
//                    
//                }];
//                [alertcontroller addAction:action];
//                [alertcontroller addAction:actionSure];
//                
//                
//                
//                [self presentViewController:alertcontroller animated:YES completion:nil];
//                
//            } else {  //版本号和app store上的一致
//                NSString *titleStr = [NSString stringWithFormat:@"检查更新：%@", trackName];
//                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:titleStr message:@"暂无新版本" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
//                alert.tag = [kAppID intValue] + 1;
//                [alert show];
//            }
       
        
        
        
        
        
        
        
        
        }
            
              break;
            case 4:
        {
            
          
            
                
                self.viewCache = [[UIView alloc]init];
                self.viewCache.backgroundColor = [UIColor colorWithRed:0.7556 green:0.7556 blue:0.7556 alpha:0.714897629310345];
                [self.view addSubview:self.viewCache];
                [self.viewCache mas_makeConstraints:^(MASConstraintMaker *make) {
                    
                    make.top.equalTo(self.view.mas_top);
                    make.bottom.equalTo(self.view.mas_bottom);
                    make.right.equalTo(self.view.mas_right);
                    make.left.equalTo(self.view.mas_left);
                }];
        
                
                UIButton *buttonCache = [UIButton buttonWithType:UIButtonTypeCustom];
                [self.viewCache addSubview:buttonCache];
                [buttonCache mas_makeConstraints:^(MASConstraintMaker *make) {
                    
                    make.top.equalTo(self.view.mas_top);
                    make.bottom.equalTo(self.view.mas_bottom);
                    make.right.equalTo(self.view.mas_right);
                    make.left.equalTo(self.view.mas_left);
                    
                    
                    
                    
                    
                }];
                [buttonCache addTarget:self action:@selector(removeCacheAction:) forControlEvents:UIControlEventTouchUpInside];
                
                
                
                
                UIView *viewNewVersion = [[UIView alloc]init];
                viewNewVersion.backgroundColor = [UIColor whiteColor];
                [buttonCache addSubview:viewNewVersion];
                [viewNewVersion.layer setCornerRadius:6.0];
                [viewNewVersion mas_makeConstraints:^(MASConstraintMaker *make) {
                    
                    make.top.equalTo(self.view.mas_top).offset(250*FitH);
                    make.bottom.equalTo(self.view.mas_bottom).offset(-275*FitH);
                    make.right.equalTo(self.view.mas_right).offset(-60*FitW);
                    make.left.equalTo(self.view.mas_left).offset(60*FitW);
                }];
                
            
            
            
                UILabel *labelVersion = [[UILabel alloc]init];
                labelVersion.font = [UIFont systemFontOfSize:20*FitW];
                [viewNewVersion addSubview:labelVersion];
                labelVersion.text = @"是否清除缓存?";
                labelVersion.textAlignment = NSTextAlignmentCenter;
                [labelVersion mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.top.equalTo(viewNewVersion.mas_top).offset(30*FitH);
                    make.left.equalTo(viewNewVersion.mas_left);
                    make.right.equalTo(viewNewVersion.mas_right);
                }];
            
            
            UIButton *buttonCancel = [UIButton buttonWithType:UIButtonTypeSystem];
           
            buttonCancel.tintColor = [UIColor redColor];
            [buttonCancel setTitle:@"取消" forState: UIControlStateNormal];
            [viewNewVersion addSubview:buttonCancel];

            [buttonCancel mas_makeConstraints:^(MASConstraintMaker *make) {
               
                make.left.equalTo(viewNewVersion.mas_left);
                make.bottom.equalTo(viewNewVersion.mas_bottom);
                make.height.mas_equalTo(45*FitH);
                make.width.mas_equalTo(128*FitW);
                
            }];
             [buttonCancel addTarget:self action:@selector(cancelAction:) forControlEvents:UIControlEventTouchUpInside];
            
            UIButton *buttonSure = [UIButton buttonWithType:UIButtonTypeSystem];
            buttonSure.tintColor = [UIColor blueColor];
            [buttonSure setTitle:@"确定" forState: UIControlStateNormal];
            [viewNewVersion addSubview:buttonSure];
          
            [buttonSure mas_makeConstraints:^(MASConstraintMaker *make) {
                
                make.left.equalTo(viewNewVersion.mas_left).offset(128*FitW);
                make.bottom.equalTo(viewNewVersion.mas_bottom);
                make.height.mas_equalTo(45*FitH);
                make.width.mas_equalTo(128*FitW);
                
            }];
           
            
            [buttonSure addTarget:self action:@selector(cacheAction:) forControlEvents:UIControlEventTouchUpInside];
            
                
                
            
                
                
                
                
            
            
        }
            break;
            
        case 5:{
            
            AboutAppViewControllerr *about = [[AboutAppViewControllerr alloc]init];
            [self.navigationController pushViewController:about animated:YES];
            
            
        }
            break;
        default:
            break;
    }
    
    
    
    
}


#pragma mark --  清除缓存

- (void)removeCacheAction:(UIButton *)button {
    [self.viewCache removeFromSuperview];
}
- (void)cancelAction:(UIButton *)button {
   [self.viewCache removeFromSuperview];
}
- (void)cacheAction:(UIButton *)button {
    
    BOOL isSuccess = [SetupCach clearCacheWithFilePath:filePathNew];
    if (isSuccess)
    {
        
        
        NSLog(@"清除成功");
        
        [self.viewCache removeFromSuperview];
        
        UILabel *labelcachefinish = [[UILabel alloc]init];
        labelcachefinish.text = @"已清除";
        labelcachefinish.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
        labelcachefinish.textColor = [UIColor whiteColor];
        [labelcachefinish.layer setMasksToBounds:YES];
        [labelcachefinish.layer setCornerRadius:8.0];
        labelcachefinish.font = [UIFont systemFontOfSize:20*FitW];
        [self.view addSubview:labelcachefinish];
        [labelcachefinish mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.bottom.equalTo(self.view.mas_bottom).offset(-60*FitH);
          
          
            make.centerX.mas_equalTo(self.view.mas_centerX);
        }];
        
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [labelcachefinish removeFromSuperview];
        });
        
        
    }

    
    
    
}

//+(void)clearCache:(NSString *)path{
//    NSFileManager *fileManager=[NSFileManager defaultManager];
//    if ([fileManager fileExistsAtPath:path]) {
//        NSArray *childerFiles=[fileManager subpathsAtPath:path];
//        for (NSString *fileName in childerFiles) {
//            //如有需要，加入条件，过滤掉不想删除的文件
//            NSString *absolutePath=[path stringByAppendingPathComponent:fileName];
//            [fileManager removeItemAtPath:absolutePath error:nil];
//        }
//    }
//    [[SDImageCache sharedImageCache] cleanDisk];
//}
//
//+(float)fileSizeAtPath:(NSString *)path{
//    NSFileManager *fileManager=[NSFileManager defaultManager];
//    if([fileManager fileExistsAtPath:path]){
//        long long size=[fileManager attributesOfItemAtPath:path error:nil].fileSize;
//        return size/1024.0/1024.0;
//    }
//    return 0;
//}









//+(float)folderSizeAtPath:(NSString *)path{
//    NSFileManager *fileManager=[NSFileManager defaultManager];
//    float folderSize;
//    if ([fileManager fileExistsAtPath:path]) {
//        NSArray *childerFiles=[fileManager subpathsAtPath:path];
//        for (NSString *fileName in childerFiles) {
//            NSString *absolutePath=[path stringByAppendingPathComponent:fileName];
//            folderSize +=[FileService fileSizeAtPath:absolutePath];
//        }
//        //SDWebImage框架自身计算缓存的实现
//        folderSize+=[[SDImageCache sharedImageCache] getSize]/1024.0/1024.0;
//        return folderSize;
//    }
//    return 0;
//}


//版本显示更新之后退出点击事件
- (void)removeeAction:(UIButton *)button {
    [self.viewVersion removeFromSuperview];
  
}


- (void)createButton {
    if (!_buttonOut) {
        
        self.buttonOut = [UIButton buttonWithType:UIButtonTypeSystem];
        _buttonOut.frame = CGRectMake(15*FitW, 356*FitH, 346*FitW, 45*FitH);
        //_buttonOut.backgroundColor = [UIColor yellowColor];
        [_buttonOut setTitle:@"退出登录" forState: UIControlStateNormal];
        _buttonOut.tintColor =[UIColor whiteColor];
        _buttonOut.backgroundColor = [UIColor colorWithHexString:@"#fd487f"];
        _buttonOut.titleLabel.font = [UIFont systemFontOfSize:20*FitW];
        [_buttonOut addTarget:self action:@selector(signOutAction:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:_buttonOut];
        [_buttonOut.layer setMasksToBounds:YES];
        [_buttonOut.layer setCornerRadius:4.0];
       
//        CAGradientLayer *gradientlayer = [CAGradientLayer layer];
//        
//        gradientlayer.frame = _buttonOut.layer.bounds;
//        
//        gradientlayer.colors = @[(id)[UIColor colorWithRed:1.0 green:0.0 blue:0.502 alpha:1.0].CGColor,
//                                 (id)[UIColor colorWithRed:1.0 green:0.8 blue:0.4 alpha:1.0].CGColor];
//        gradientlayer.startPoint = CGPointMake(0, 1);
//        gradientlayer.endPoint = CGPointMake(1, 0);
//        gradientlayer.masksToBounds = YES;
//        gradientlayer.borderWidth = 1.0;
//        gradientlayer.bounds = CGRectMake(15*FitW, 356*FitH, 346*FitW, 45*FitH);
//        [_buttonOut.layer addSublayer:gradientlayer];
        
        
        

        
        
    
    }
    
    
}

- (void)signOutAction:(UIButton *)button {
    NSLog(@"退出登录");
}









- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
